<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>待审批详情页</title>
    <link rel="stylesheet" href="../../lib/layui/css/layui.css"/>
    <style type="text/css">
        .addresslayer {
            padding: 10px;
            width: 94%;
            height: 90%;
            margin: 10px auto;
            display: none;
        }

        .operation_title_m {
            font-size: 16px;
        }

        .textarea {
            margin-right: 3px;
        }

        .divarea {
            margin-bottom: 5px;
        }
        .tub{
            font-size: 16px;
            margin-right: 5px;
        }
    </style>
</head>
<body>
<div class="ok-body" style="background: #F8F8F8">
    <div class="layui-row ">
        <div class="layui-col-md9" style="background-color:#f8f8f8;">
            <div class="layui-row">
                <hr class="layui-bg-gray">
                <fieldset class="layui-elem-field">
                    <legend>警情详情
                        <span class="layui-badge layui-bg-blue">待审批</span>
                    </legend>
                    <div class="layui-field-box " style="margin-left: 20px;">
                        <div class="layui-row">
                            <div class="layui-col-md9">
                                <div class="divarea">
                                    <i class="tub layui-icon layui-icon-username" style="color: #1E9FFF;"></i>
                                    <sapn class="textarea">处理人 : <span id="handleUser">加载中</span></sapn>
                                </div>
                                <div class="divarea">
                                    <i class="tub layui-icon layui-icon-home" style="color: #FF5722;"></i>
                                    <sapn class="textarea">处理单位 : <span id="procDepartment">加载中</span></sapn>
                                </div>
                                <div class="divarea">
                                    <i class="tub layui-icon layui-icon-log" style="color: #FFB800;"></i>
                                    <sapn class="textarea">分派时间 : <span id="askForTime">加载中</span></sapn>
                                </div>
                            </div>
                        </div>
                    </div>
                    <hr class="layui-bg-gray">
                    <div>
                        <div style="background: #d2d2d2">
                            <div style="width: 80%;height: 100%;margin: 0 auto;">
                                <div class="layui-collapse" lay-filter="caseData">
                                    <div class="layui-colla-item">
                                        <h2 class="layui-colla-title" style="font-size: 16px" ><span id="caseDataChange">隐藏</span>警情信息</h2>
                                        <div class="layui-colla-content layui-show" style="background-color:#fdfdfd;">
                                            <div style="background-color:#fdfdfd;">
                                                <iframe scrolling="no" frameborder="0" src="../caseCommonData/caseData.html" width="100%"
                                                        height="700px" id="caseData"
                                                        onload="this.height=0;var fdh=(this.Document?this.Document.body.scrollHeight:this.contentDocument.body.offsetHeight);this.height=(fdh>700?fdh:700);"></iframe>
                                            </div>
                                        </div>
                                    </div>
                                </div>

                                <div style="background-color:#fdfdfd;margin-top: 10px;padding-top: 20px;">
                                    <iframe scrolling="no" frameborder="0" src="../caseCommonData/processData.html" width="100%"
                                            height="700px" id="processData"
                                            onload="this.height=0;var fdh=(this.Document?this.Document.body.scrollHeight:this.contentDocument.body.offsetHeight);this.height=(fdh>700?fdh:700)"></iframe>
                                </div>
                            </div>

                        </div>
                    </div>

                </fieldset>

            </div>
        </div>
        <div class="layui-col-md3" style="background-color:#f8f8f8;">
            <hr class="layui-bg-gray">
            <fieldset class="layui-elem-field">
                <legend style="font-size: 20px">上一个处理信息</legend>

                <div style="background-color: #f8f8f8;height: auto;margin:15px 20px 0 30px">
                    <form class="layui-form" action="">

                        <div class="layui-form-item">
                            <i class="tub layui-icon layui-icon-username" style="color: #1E9FFF;"></i>
                            <label>处理人 : </label>
                            <span id="procpoliceName">加载中</span>
                        </div>

                        <div class="layui-form-item">
                            <i class="tub layui-icon layui-icon-log" style="color: #FFB800;"></i>
                            <label>处理时间： </label>
                            <span id="procedate">加载中</span>
                        </div>

                        <div class="layui-form-item">
                            <i class="tub layui-icon layui-icon-read" style="color: #009688;"></i>
                            <label>处理意见： </label>
                            <span id="procremark">加载中</span>
                        </div>
                    </form>

                </div>
            </fieldset>
            <br>
            <br>
            <br>
            <fieldset class="layui-elem-field">
                <legend style="font-size: 20px">警情审批</legend>

                <div style="background-color: #f8f8f8;height: auto;margin:10px 20px 0 20px">

                    <form class="layui-form" action="">
                        <div class="layui-input-block" style="margin-left: 0px" id="redioResult">
                            <input type="radio" lay-filter="auditResults" checked="" name="auditResults" value="0" title="通过并办结" id="passOne">
                            <input type="radio" lay-filter="auditResults" name="auditResults" value="1" title="回退" id="back">
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-form-item layui-form-text" style="margin: 10px">
                                处理意见：
                            </div>
                            <div>
                                <textarea name="checkContent" required lay-verify="required" placeholder="请填写处理意见..."
                                          class="layui-textarea"></textarea>
                            </div>

                        </div>


                        <div class="layui-form-item">
                            <button type="button" class="layui-btn" lay-submit lay-filter="add" id="submit" style="float: right">提交
                            </button>
                        </div>

                    </form>

                </div>
            </fieldset>

        </div>
    </div>
</div>
</div>

<script type="text/javascript" src="../../lib/layui/layui.all.js"></script>
<script type="text/javascript" src="../../js/jquery-3.3.1.js"></script>
<script src="../../js/application.js"></script>

<script>
    var processId = GetQueryString("processid")
    var caseId = GetQueryString("caseid")
    var staticId = 5
    var nextPoliceId = ""//下一个处理者
    var nextDepartmentName = ""//下一个处理部门



    layui.use(['form', 'element', 'laydate','element'], function(){
        var $ = layui.jquery
            ,layer = layui.layer
            ,form = layui.form
            ,element = layui.element;

        var policeInfo = JSON.parse(window.sessionStorage.getItem("police"));


        //数据绑定
        $.ajax({
            url: mainUri + '/caseProcInfo/selectCaseProcInfo',
            data: {
                'parentId':0,
                'processId': processId
            },
            type: "post",
            dataType: "json",
            success: function (data){
                if (data.code==0){
                    $("#handleUser").html(data.data.nfullName);//处理者
                    $("#procDepartment").html(data.data.departmentName)//处理单位
                    $("#askForTime").html(data.data.askForTime);//分派时间
                    nextPoliceId = data.data.nextPoliceId;
                    nextDepartmentName = data.data.departmentName;
                }
            },
            error: function (){
                alert("服务器错误");
            }
        });

        //数据绑定
        $.ajax({
            url: mainUri + '/VCaseProcInfoByPolice/selectVCaseProcInfoByStatusPro',
            data: {
                'processId': processId
            },
            type: "post",
            dataType: "json",
            success: function (data){
                if (data.code==0){
                    $("#procpoliceName").html(data.data[0].fullName);//上一个处理信息的处理人
                    $("#procedate").html(data.data[0].proceDate);//处理时间
                    $("#procremark").html(data.data[0].procreMark);//处理意见

                }
            },
            error: function (){
                alert("服务器错误");
            }
        });



        //判断是否回退or通过并办结
        form.on("radio(auditResults)", function (data) {
            var num = data.value;
            if (num == 0) {
                staticId = 5
                nextDepartmentName = ""//下一个处理部门
                nextPoliceId = ""//下一个处理者
            } else {
                staticId = 1
            }
        });
        //警情审批
        form.on("submit(add)", function (data) {
            layer.confirm('确定提交?', {icon: 3, title: '提示'}, function (index) {
                showloading(true)
                var nDepartmentName = nextDepartmentName;
                var nPoliceId = nextPoliceId
                if (staticId == 5) {
                    nDepartmentName = "";
                    nPoliceId = "";
                }
                var checkCase = data.field;
                $.ajax({
                    url: mainUri + "/caseOperNote/insert",
                    data: {
                        "processId": processId,
                        "staticId": staticId,
                        "procRemark": checkCase.checkContent,
                        "nextDepartmentName": nDepartmentName,
                        "nextPoliceId": nPoliceId,
                    },
                    type: "post",
                    dataType: "json",
                    success: function (result) {
                        showloading(false)
                        if (result.code == 0) {
                            layer.msg(result.msg, {
                                icon: 1, time: 1500, end: function () {
                                    window.opener.location.href = window.opener.location.href;
                                    window.close();
                                }
                            })
                        }
                    },
                    error: function () {
                        showloading(false)
                        alert("服务器错误");
                    }
                });
            })
        });

        // 警情详情页隐藏和显示
        let processDataHeight=0
        element.on('collapse(caseData)', function(data){
            if(processDataHeight==0){
                processDataHeight=$("#processData").height();
            }
            if(!data.show){
                if(processDataHeight<800){
                    $("#processData").height(800)
                }
                $("#caseDataChange").html("显示")
            }else{
                $("#processData").height(processDataHeight)
                $("#caseDataChange").html("隐藏")
            }
        });
    });
    //警情详细页
    getCaseData(caseId)
    function getCaseData(caseId) {
        $("#caseData").on("load", function () {
            var data = {caseId: caseId}
            this.contentWindow.getParentData(data)
        })
    }
    //处理过程页
    getprocessData(processId)
    function getprocessData(processId) {
        $("#processData").on("load", function () {
            var data = {processId: processId}
            this.contentWindow.getParentData(data)
        })
    }



    function caseReturnData(returnData) {

    }

    function processReturnData(returnData) {
        $("#processData").height(returnData.height)
        processDataHeight = returnData.height
    }
    //详细处理过程文件下载页
    function showProcessContent(clickId) {
        layui.use(['element','layer','okLayer'], function () {
            let okLayer = layui.okLayer;
            okLayer.open("查询条件", "../caseCommonData/fileData.html?processId=" + clickId, "35%", "50%", function (layero) {
                let iframeWin = window[layero.find("iframe")[0]["name"]];
            }, function () {

            })
        })
    }

</script>
</body>
</html>
